package com.triones.api.controller.api;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.triones.api.entity.vo.HelpCategorizeVO;
import com.triones.api.entity.vo.HelpVO;
import com.triones.api.service.HelpService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * api - 帮助中心相关接口
 *
 * @Author: triones
 */
@SaIgnore
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/help")
public class ApiHelpController extends BaseController {

    private final HelpService helpService;

    /**
     * 分类列表
     */
    @GetMapping(value = "/categorize/list")
    public R<List<HelpCategorizeVO>> categorizeList() {
        return R.ok(helpService.apiCategorizeList());
    }

    /**
     * 帮助内容列表
     */
    @GetMapping(value = "/list/{cid}")
    public R<List<HelpVO>> helpList(@NotNull(message = "主键不能为空") @PathVariable Long cid,String keyword) {
        return R.ok(helpService.apiHelpList(cid, keyword));
    }
}
